package com.rui.iterator.model;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 容器接口实现类
 * @Author: ZhangRui
 * @Date: 2023/3/3 16:45
 * @Version: 1.0
 */
public class AggregateImpl<T> implements Aggregate<T> {

    private List<T> list = new ArrayList<>();

    @Override
    public void add(T t) {
        list.add(t);
    }

    @Override
    public void remove(T t) {
        list.remove(t);
    }

    @Override
    public Iterator<T> iterator() {
        return new IteratorImpl<>(list);
    }
}
